package tcp

import (
	"fmt"
	"os"
	"time"
)

func SelectDemo() {

	abort := make(chan struct{})
	go func() {
		os.Stdin.Read(make([]byte, 1)) // 读一个字节进来
		abort <- struct{}{}
	}()

	tick := time.Tick(1 * time.Second)
	for i := 10; i > 0; i-- {
		select {
		case <-tick:
			// do nothing
			fmt.Println("Launch after ", i, " seconds!")
		case <-abort:
			fmt.Println("Launch aborted !")
			return
		}
	}
	launch()

}

func launch() {

	fmt.Println("launch success .......")
}
